package cn.lzit.session;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(name="LoginServlet",urlPatterns = "/LoginServlet")
public class LoginServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    protected void doGet(HttpServletRequest request, HttpServletResponse
            response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        request.setCharacterEncoding("utf-8");
        String name =request.getParameter("name");
        if (name == null)
            name = "";
        else
            request.setAttribute("customerName",name);
        if (name.length() > 0) {
            String url = "<A href='food.html'> 欢迎去食品柜台！</A>";
            response.getWriter().print("点击超链接，链接到food.html页面,去采购食品。<br />" + url);
        } else {
            response.sendRedirect("/chapter05/login.html");
        }
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        // TODO Auto-generated method stub
        doGet(request, response);
    }
}
